package ibatis;

import java.sql.SQLException;

import com.ibatis.sqlmap.client.SqlMapClient;

import data.Sequence;

public class SeedProvider {

	
	
	public synchronized static int getSeed(String name) throws SQLException{
		SqlMapClient sd=SqlConfig.getSqlMapInstance();
		
		int seed=-1;
		Sequence se=(Sequence)sd.queryForObject("getSequence", name);
		seed=se.getNextId();
		int nextseed=seed+1;
		se.setNextId(nextseed);
		sd.update("updateSequence",se);
		
		return seed;
	}
}
